package com.itheima.controller;

import com.itheima.service.DataSyncService;
import entity.Result;
import entity.StatusCode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@RestController
@RequestMapping("/datasync")
public class DataSyncController {

    @Autowired
    private DataSyncService dataSyncService;

    @GetMapping("/importAll")
    public Result importAll(){
        dataSyncService.importAll();
        return new Result(true, StatusCode.OK,"操作成功");
    }

    @GetMapping("/{s}")
    public Result searchOne(@PathVariable("s") String s) throws IOException {

        return dataSyncService.searchOne(s);
    }

}
